#include <stdio.h>
#include <mpx_supt.h>


date_rec* dateP = new date_rec;
void help()
{
	printf("\n\n This is a comprehensive list of commands and how they're used.\n COMMAND: \t\t\t\t DESCRIPTION:\n");
	printf("\t date \t\t\t Displays current date.\n \t     -s \t\t\t argument used to set date. ex datge -s mm/dd/yyyy \n");
	printf("\t ls \t\t Displays contents of directory specified. \n\t\t\t\t Displays . (current directory) by default.\n\t\t\t\t ex dispD /path/dir \n");
	printf("\t help \t\t\t Displays this help menu.\n");
	printf("\t vrsn \t\t\t Displays version of MPX. \n");
	printf("\t exit \t\t\t Used to exit the program. \n");

}

void display_version()
{
	printf("\nVersion 1.0\n\n");
}

void display_date()
{
	sys_get_date(dateP);
	printf("\n%d/", dateP->month);
	printf("%d/", dateP->day);
	printf("%d\n\n", dateP->year);
}

void set_date(int m, int d, int y)
{
	int valid = 1;           //date validation parameter

	if(y<0) {valid=0;}    //Year is a negative number

	if(m>12 || m<1) {valid=0;} //Month must be 1-12

	if(m==2 && d>28) {valid=0;}  //28 days in feb

	else if((m==4 || m==6 || m==9 || m==11) && d>30) {valid=0;}//30 days

	else if((m==1 || m==3 || m==5 || m==7 || m==8
	|| m==10 || m==12) && d>31) {valid=0;}        //31 day months



	if(valid)           //Valid date, execute sys_set_date()
	{
		dateP->month = m;
		dateP->day = d;
		dateP->year = y;
		sys_set_date(dateP);
	}

	else if(valid==0)
	{ printf("Invalid date, please try again.\n");}
}


void terminateMPX()
{
	sys_exit();
}
